<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.model.ParamCourseScoreGS"%>
<%@page import="com.is.control.ParamCourseScoreGSControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<body>
<%
				     int courseId =ParamUtil.getInt(request,"courseId",0);
				     int classId = ParamUtil.getInt(request,"classId");
				     int uid = ParamUtil.getInt(request,"uid");
				     String prevTotalClass = ParamUtil.getString(request,"prevTotalClass","0");
				     CourseClass cc = new CourseClass();
				     cc.setClassId(classId);
				     cc.setCourseId(courseId);
				     cc.setPrevTotalClass(prevTotalClass);
				     cc.setRealTotalClass("0");
				     cc.setUid(uid);
				     cc.setStuyear(ParamStuyearControl.getCurrentStuyearId());
				     cc.setState(0);
				     
				     if(!CourseClassControl.isInserted(ParamStuyearControl.getCurrentStuyearId(),courseId,classId)){
				    	     int flag = CourseClassControl.insertCourseClass(cc);
						     if(flag!=0){
						    	 String dailyPer = ParamUtil.getString(request,"daily","0.0");
							     String midPer = ParamUtil.getString(request,"mid","0.0");
							     String finalPer = ParamUtil.getString(request,"final","0.0");
							     ParamCourseScoreGS csgs = new ParamCourseScoreGS(flag,dailyPer,midPer,finalPer);
							     if(ParamCourseScoreGSControl.insertGS(csgs)){
							    	  %>
								         <script>
								       //  $.dialog('简单愉悦的接口，强大的表现力，优雅的内部实现', function(){alert('yes');});
								         window.location.href="set.jsp";
								         </script>
								         <%
							       }else{
							    	   %>
								        <script>
						         $.dialog({
									    title: '课程分配',
									    content: '插入总成绩分配数值失败',
									    icon: 'warning',
									    ok: function(){
						        			 window.location.href='set.jsp';
									    }
									});
						        
						         </script>
								         <%
							       }
						     }else{
						     %>
						         <script>
						         $.dialog({
									    title: '课程分配',
									    content: '分配课程失败，请检查自己的操作是否有误再重试',
									    icon: 'warning',
									    ok: function(){
						        			 window.location.href='set.jsp';
									    }
									});
						        
						         </script>
						         <%
						     }
				     }else{
				    	 %>
				         <script type="text/javascript">
				         $.dialog('您填写的课程班次记录已存在，请检查您的填写内容', function(){
				                window.location.href="set.jsp";
				                });
				         </script>
				         <%
				     }
 %>
</body>
</html>